package com.reason.user.controller;



import com.reason.common.pojo.Result;
import com.reason.common.pojo.StatusCode;
import com.reason.user.pojo.LifeStyle;
import com.reason.user.service.LifeStyleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author  yulongjun
 * @date 2020/6/29 10:42 下午
 */
@RestController
@RequestMapping("/life")
public class LifeStyleController {
    @Autowired
    private LifeStyleService lifeService;
    /**
     * 查询所有
     * @return
     */
    @GetMapping("/findAll")
    public Result<List<LifeStyle>> findAll(){
        List<LifeStyle> lives=lifeService.findAll();
        return new Result<List<LifeStyle>>(true, StatusCode.OK,"查询成功",lives);
    }
    /**
     * 根据ID查询LifeStyle
     * @param Id
     * @return
     */
    @GetMapping("/findById/{Id}")
    public LifeStyle findById(@PathVariable("Id") Long Id){
        LifeStyle lifeStyle=lifeService.findByID(Id);
        if(lifeStyle==null){
            return null;
        }
        return lifeStyle;
    }

}
